let { observable, observe,computed,autorun,when,action} = require("mobx");

class Person {
    @observable age = 12;
    @observable name = "heml";
    @observable city ="朝阳";
    @observable area = "010";
    @observable photo = "1594569778"

    @computed get home(){
        return `${this.city}-${this.area}`
    }
    @action.bound newhome(city,area){
        return `${this.city}-${this.area}`
    }
}
 let p1 = new Person();
// observe(p1,c=>console.log(c));
// p1.name = "html1";
 
// let photo = computed(()=>{
//     return  p1.area +"_"+p1.photo;
// });
// photo.observe(c=>console.log(c));
//p1.area = "202";
//console.log(p1.home) //得到 get home 方法的值， 不带小（）；

autorun(()=>{
    console.log(p1.home)
})
// p1.area = "300";
// p1.city = "河北"
//p1.newhome("河北","0111");

//改成 下面的就会报 解决办法改变this指针

let s = p1.newhome;
s("河北","0011")
// setTimeout(()=>{
//     p1.area = "303"
// })


// setInterval(()=>{
//     //
//     p1.age ++;

// },1000)
// let disposer = when(()=>p1.age>=18,()=>{
//     console.log(p1.age)
// })

// disposer();

